package br.al.proativa.Utilidades.dateTime.testes;

import javax.security.auth.login.FailedLoginException;

import org.junit.Assert;
import org.junit.Test;

import br.al.proativa.Utilidades.dateTime.Horario;

public class HorarioTest {
	@Test
	public void TestConstrutorHoraNegativa(){
		try {
			new Horario( -1, 5, 12, 345 );	Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorHoraNegativa2(){
		try {	new Horario( -15, 5, 12, 345 ); 	Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorHora24(){
		try {	new Horario( 24, 5, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorHoraMaiorQue24(){
		try {	new Horario( 25, 5, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMinutoNegativo(){
		try {	new Horario( 4, -1, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMinutoNegativo2(){
		try {	new Horario( 4, -8, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMinuto60(){
		try {	new Horario( 4, 60, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMinutoMaiorQue60(){
		try {	new Horario( 4, 61, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMinutoMaiorQue60_2(){
		try {	new Horario( 4, 91, 12, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorSegundoNegativo(){
		try {	new Horario( 4, 12, -1, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorSegundoNegativo2(){
		try {	new Horario( 4, 12, -15, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorSegundo60(){
		try {	new Horario( 4, 12, 60, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorSegundoMaiorQue60(){
		try {	new Horario( 4, 12, 61, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorSegundoMaiorQue60_2(){
		try {	new Horario( 4, 12, 81, 345 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMilisegundoNegativo(){
		try {	new Horario( 4, 12, 41, -1 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMilisegundoNegativo2(){
		try {	new Horario( 4, 12, 41, -156 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMilisegundo1000(){
		try {	new Horario( 4, 12, 41, 1000 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMilisegundoMaiorQue1000(){
		try {	new Horario( 4, 12, 41, 1001 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorMilisegundoMaiorQue1000_2(){
		try {	new Horario( 4, 12, 41, 2674 );		Assert.fail( );
		} catch (IllegalArgumentException e) {	}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConstrutorValoresValidos(){
		try {	
			new Horario( 4, 12, 41, 674 );		
			new Horario( 0, 0, 0, 0 );
			new Horario( 0, 0, 0, 999 );
			new Horario( 0, 0, 59, 999 );
			new Horario( 0, 59, 59, 999 );
			new Horario( 23, 59, 59, 999 );
			new Horario( 23, 00, 00, 999 );
			new Horario( 23, 12, 25, 1 );
		} catch (IllegalArgumentException e) {
			Assert.fail( );
		}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestSemValorComHora(){
		if( new Horario( 1,0,0,0 ).semValor() ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestSemValorComMinuto(){
		if( new Horario( 0,1,0,0 ).semValor() ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestSemValorComSegundo(){
		if( new Horario( 0,0,1,0 ).semValor() ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestSemValorComMilisegundo(){
		if( new Horario( 0,0,0,1 ).semValor() ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestSemValorComTudo(){
		if( new Horario( 11,12,12,1 ).semValor() ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestSemValorComValorValido(){
		if( !( new Horario( 0,0,0,0 ).semValor() ) ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestCriarHorarioVazio(){
		Horario h = Horario.criarHorarioVazio();
		if( h.getHoras() != 0 || h.getMinutos() != 0 || h.getSegundos() != 0 || h.getMilisegundos() != 0){
			Assert.fail();
		}
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_12_11_14_024(){
		Horario h = new Horario( 12, 11, 14, 24 );
		if( h.converterParaInteiro( false ) != 121114) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_05_03_01_024(){
		Horario h = new Horario( 5, 3, 1, 24 );
		if( h.converterParaInteiro( false ) != 50301);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_00_03_01_024(){
		Horario h = new Horario( 0, 3, 1, 24 );
		if( h.converterParaInteiro( false ) != 301);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_00_00_01_024(){
		Horario h = new Horario( 0, 0, 1, 24 );
		if( h.converterParaInteiro( false ) != 1);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_00_00_00_024(){
		Horario h = new Horario( 0, 0, 0, 24 );
		if( h.converterParaInteiro( false ) != 0);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_01_00_00_024(){
		Horario h = new Horario( 1, 0, 0, 24 );
		if( h.converterParaInteiro( false ) != 10000);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_01_00_34_024(){
		Horario h = new Horario( 1, 0, 34, 24 );
		if( h.converterParaInteiro( false ) != 10034);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_semMili_ComHora_00_59_59_024(){
		Horario h = new Horario( 0, 59, 59, 24 );
		if( h.converterParaInteiro( false ) != 5959);
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_12_11_14_024(){
		Horario h = new Horario( 12, 11, 14, 24 );
		if( h.converterParaInteiro( true ) != 121114024) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_05_03_01_024(){
		Horario h = new Horario( 5, 3, 1, 24 );
		if( h.converterParaInteiro( true ) != 50301024) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_00_03_01_024(){
		Horario h = new Horario( 0, 3, 1, 24 );
		if( h.converterParaInteiro( true ) != 301024) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_00_00_01_024(){
		Horario h = new Horario( 0, 0, 1, 241 );
		if( h.converterParaInteiro( true ) != 1241) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_00_00_00_024(){
		Horario h = new Horario( 0, 0, 0, 241 );
		if( h.converterParaInteiro( true ) != 241) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_01_00_00_024(){
		Horario h = new Horario( 1, 0, 0, 24 );
		if( h.converterParaInteiro( true ) != 10000024) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_01_00_34_999(){
		Horario h = new Horario( 1, 0, 34, 999 );
		if( h.converterParaInteiro( true ) != 10034999) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_00_59_59_024(){
		Horario h = new Horario( 0, 59, 59, 24 );
		if( h.converterParaInteiro( true ) != 5959024) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_00_00_00_000(){
		Horario h = new Horario( 0, 0, 0, 0 );
		if( h.converterParaInteiro( true ) != 0) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestConverterParaInteiro_comMili_ComHora_00_12_00_001(){
		Horario h = new Horario( 0, 12, 0, 1 );
		if( h.converterParaInteiro( true ) != 1200001) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_05_12_12_001(){
		if( new Horario( 5, 12, 12, 1 ).mili() != 18732001 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_23_59_59_999(){
		if( new Horario( 23, 59, 59, 999 ).mili() != 86399999 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_00_12_12_001(){
		if( new Horario( 0, 12, 12, 1 ).mili() != 732001 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_00_01_12_001(){
		if( new Horario( 0, 1, 12, 1 ).mili() != 72001 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_00_00_12_001(){
		if( new Horario( 0, 0, 12, 1 ).mili() != 12001 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_00_00_00_001(){
		if( new Horario( 0, 0, 0, 1 ).mili() != 1 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestMiliComHora_00_00_00_000(){
		if( new Horario( 0, 0, 0, 0 ).mili() != 0 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_00_00(){
		if( new Horario( 0, 0, 0, 0 ).getTotalDeMinutos( ) != 0 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_00_01(){
		if( new Horario( 0, 1, 0, 0 ).getTotalDeMinutos( ) != 1 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_00_45(){
		if( new Horario( 0, 45, 0, 0 ).getTotalDeMinutos( ) != 45 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_01_45(){
		if( new Horario( 1, 45, 0, 0 ).getTotalDeMinutos( ) != 105 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_09_45(){
		if( new Horario( 9, 45, 0, 0 ).getTotalDeMinutos( ) != 585 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_15_45(){
		if( new Horario( 15, 45, 0, 0 ).getTotalDeMinutos( ) != 945 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeMinutos_comHora_23_59(){
		if( new Horario( 23, 59, 0, 0 ).getTotalDeMinutos( ) != 1439 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_00_00(){
		if( new Horario( 0, 0, 0, 0 ).getTotalDeSegundos( ) != 0 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_00_01_12(){
		if( new Horario( 0, 1, 12, 0 ).getTotalDeSegundos() != 72 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_00_45_20(){
		if( new Horario( 0, 45, 20, 0 ).getTotalDeSegundos( ) != 2720 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_01_45_55(){
		if( new Horario( 1, 45, 55, 0 ).getTotalDeSegundos( ) != 6355 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_09_45_01(){
		if( new Horario( 9, 45, 1, 0 ).getTotalDeSegundos( ) != 35101 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_15_45_00(){
		if( new Horario( 15, 45, 0, 0 ).getTotalDeSegundos( ) != 56700 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	@Test
	public void TestGetTotalDeSegundos_comHora_23_59_59(){
		if( new Horario( 23, 59, 59, 0 ).getTotalDeSegundos( ) != 86399 ) Assert.fail();
	}
	//_____________________________________________________________________________________________
	//_____________________________________________________________________________________________
}
